<template>
  <!-- 采购记录 -->
  <div style="padding:20px 20px;">
    <el-card class="xiu_box">
      <div style="width:100%;height:40px;">
        <el-input clearable @keyup.enter.native="page=1;git_act()" style="width:302px;" placeholder="输入物品名称搜索" v-model="recru" class="input-with-select">
          <el-button @click='page=1;git_act()' slot="append" icon="el-icon-search"></el-button>
        </el-input>
      </div>
      <el-table v-loading="loading" :data="tableData"　  style="width:100%;margin-top:20px;">
        <el-table-column header-align='center' align='center' prop="username" label="申请人" ></el-table-column>
        <el-table-column header-align='center' align='center' prop="depName" label="部门" ></el-table-column>
        <el-table-column header-align='center' align='center' prop="name" label="名称" ></el-table-column>
        <el-table-column header-align='center' align='center' prop="typeId" label="类型" >
          <template slot-scope="scope">{{id_name(scope.row.typeId,$store.state.user.leidata)}}</template>
        </el-table-column>
        <el-table-column header-align='center' align='center' prop="amount" label="申请数量" ></el-table-column>
        <el-table-column header-align='center' align='center' prop="price" label="单价">
          <template slot-scope="scope">{{scope.row.price}} ￥</template>
        </el-table-column>
        <el-table-column header-align='center' align='center' prop="" label="金额">
          <template slot-scope="scope">{{scope.row.amount*scope.row.price}} ￥</template>
        </el-table-column>
        <el-table-column header-align='center' align='center' prop="remarks" label="状态" show-overflow-tooltip>
          <template slot-scope="scope">
            <a :style="{color:(scope.row.reason)?'red':(scope.row.isDone==1?'#67C23A':'#E6A23C')}">{{typenum(scope.row)}}</a>
          </template>
        </el-table-column>
        <el-table-column header-align='center' align='center' width="170" label="操作">
          <template slot-scope="scope">
            <el-button v-if="typenum(scope.row)=='未入库'"  @click="cgselects(true,scope.row)" type="success">入库</el-button>
            <el-button v-else   @click="cgselects(false,scope.row)">详细</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination :current-page='page' v-show='totals>15' style='margin-top:35px;width:100%;text-align:center;'
                     background @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="ye_s"
                     :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="totals">
      </el-pagination>
    </el-card>
    <CgjlChild :edit="edit" ref="procurmentchild"></CgjlChild>
  </div>
</template>
<script>
  import { queryApply } from '@/api_bast/Finance.js'
  import CgjlChild from '@/components/MES/procur/CgjlChild.vue'
  export default {
    components: {CgjlChild},//声明子组件
    computed:{
       typenum(){
         return (item)=>{
             return item.reason?'驳回':(item.isDone==1?'已入库':(item.isDone==3?'审核中':'未入库'));
         }
       }

    },
    data(){
      return {
        edit:true,
        loading:false,
        tableData:[],
        page:1,
        size:15,
        totals:0,
        ye_s:[15,20],
        recru:'',//查询条件
      }
    },
    methods:{
      cgselects(bolen,num){
        console.log(num)
        this.edit = bolen;
        this.$refs.procurmentchild.panertfn(num);
      },
      goto(){

      },
      git_act(){//获取数据列表
        let dat= {
          pageNo:this.page,
          pageSize:this.size,
          // name:this.recru
        };
        this.loading=true;
        queryApply(1,dat).then(response => {
          this.loading = false;
          if(!response.resData){return false;}
          this.totals = response.resData.total;
          this.tableData = response.resData.list;
        })
      },
      handleCurrentChange(val) {//点击页数
        this.page = val;
        this.git_act();
      },
      handleSizeChange(val) {//点击条数
        this.size = val;
        this.git_act();
      },
    },
    mounted(){
      this.git_act();//获取数据
    },
  }
</script>

<style scoped="scoped">
  .xiu_box{width: 100%;}
  .btn{padding:10px 5px;}
</style>
